project(Common)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 查找源文件
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")

# 创建库
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})

# 设置CTP头文件路径
set(CTP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/ThirdParty/CTP/include" CACHE PATH "CTP header files directory")

# 设置包含目录
target_include_directories(${PROJECT_NAME}
    PUBLIC 
        ${CMAKE_CURRENT_SOURCE_DIR}/include
        ${CTP_INCLUDE_DIR}
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/src
)

# 查找依赖库
find_package(spdlog REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(Qt5 COMPONENTS Core Network REQUIRED)

# 链接依赖库
target_link_libraries(${PROJECT_NAME}
    PUBLIC
        spdlog::spdlog
        nlohmann_json::nlohmann_json
        Qt5::Core
        Qt5::Network
        stdc++fs
)